﻿Namespace My
    <HideModuleName()> _
    Module StringHelpers
        Private mHelper As New ThreadSafeObjectProvider(Of MyStringHelper)
        Friend ReadOnly Property StringHelper() As MyStringHelper
            Get
                Return mHelper.GetInstance()
            End Get
        End Property
    End Module

    <System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
    Friend NotInheritable Class MyStringHelper
        Friend Function ParseString(ByVal stringToParse As String, ByVal pairSeparator As Char, ByVal valueSeparator As Char) As Dictionary(Of String, String)
            Dim dict As New Dictionary(Of String, String)
            Dim nameValues = From pair In stringToParse.Split(pairSeparator), values In pair.Split(valueSeparator) _
                                Select New With {.Name = values(0), .Value = values(1)}
            For Each nv In nameValues
                dict.Item(nv.Name) = nv.Value
            Next
            mParseCount += 1
            Return dict
        End Function

        Private mParseCount As Integer = 0
        Friend ReadOnly Property ParseCount() As Integer
            Get
                Return mParseCount
            End Get
        End Property
    End Class
End Namespace
